From 00eb2b2ff1a02409fdc619e7f76ef1600b068843 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Sun, 20 May 2007 21:28:48 -0600 Subject: [PATCH] [IA64] Fix xen/ia64 save/restore error recovery path. Signed-off-by: Isaku Yamahata --- tools/libxc/ia64/xc_ia64_linux_restore.c | 8 +++++++- tools/libxc/ia64/xc_ia64_linux_save.c | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/libxc/ia64/xc_ia64_linux_restore.c b/tools/libxc/ia64/xc_ia64_linux_restore.c index 44d500cd89..21d0e09f1e 100644 --- a/tools/libxc/ia64/xc_ia64_linux_restore.c +++ b/tools/libxc/ia64/xc_ia64_linux_restore.c @@ -48,10 +48,11 @@ read_page(int xc_handle, int io_fd, uint32_t dom, unsigned long pfn) PROT_READ|PROT_WRITE, pfn); if (mem == NULL) { ERROR("cannot map page"); - return -1; + return -1; } if (!read_exact(io_fd, mem, PAGE_SIZE)) { ERROR("Error when reading from state file (5)"); + munmap(mem, PAGE_SIZE); return -1; } munmap(mem, PAGE_SIZE); @@ -270,6 +271,7 @@ xc_domain_restore(int xc_handle, int io_fd, uint32_t dom, } if (!read_exact(io_fd, shared_info, PAGE_SIZE)) { ERROR("Error when reading shared_info page"); + munmap(shared_info, PAGE_SIZE); goto out; } @@ -286,6 +288,10 @@ xc_domain_restore(int xc_handle, int io_fd, uint32_t dom, /* Uncanonicalise the suspend-record frame number and poke resume rec. */ start_info = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE, gmfn); + if (start_info == NULL) { + ERROR("cannot map start_info page"); + goto out; + } start_info->nr_pages = p2m_size; start_info->shared_info = shared_info_frame << PAGE_SHIFT; start_info->flags = 0; diff --git a/tools/libxc/ia64/xc_ia64_linux_save.c b/tools/libxc/ia64/xc_ia64_linux_save.c index 8fcd9d0a9d..ceb91795c4 100644 --- a/tools/libxc/ia64/xc_ia64_linux_save.c +++ b/tools/libxc/ia64/xc_ia64_linux_save.c @@ -361,11 +361,13 @@ xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, if (!write_exact(io_fd, &N, sizeof(N))) { ERROR("write: max_pfn"); + munmap(mem, PAGE_SIZE); goto out; } if (write(io_fd, mem, PAGE_SIZE) != PAGE_SIZE) { ERROR("Error when writing to state file (5)"); + munmap(mem, PAGE_SIZE); goto out; } munmap(mem, PAGE_SIZE); @@ -470,6 +472,7 @@ xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, } if (write(io_fd, mem, PAGE_SIZE) != PAGE_SIZE) { ERROR("Error when writing privreg to state file (5)"); + munmap(mem, PAGE_SIZE); goto out; } munmap(mem, PAGE_SIZE); -- 2.30.2